-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix setting ServerAddress property in NativeStore #4655
Fix setting ServerAddress property in NativeStore #4655
Conversation
Thanks! We also merged a fix on the daemon-side in moby/moby#46779 Perhaps both won't do harm though /cc @dmcgowan |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4655 +/- ##
=======================================
Coverage 59.74% 59.75%
=======================================
Files 288 288
Lines 24849 24853 +4
=======================================
+ Hits 14846 14850 +4
Misses 9117 9117
Partials 886 886 |
@@ -76,6 +77,7 @@ func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) { | |||
ac.Username = creds.Username | |||
ac.Password = creds.Password | |||
ac.IdentityToken = creds.IdentityToken | |||
ac.ServerAddress = creds.ServerAddress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is ac.ServerAddress
ever a non-empty value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not believe so no. Since in both stores the code always sets it to what the Registry Hostname is. Is your idea to just have creds be returned there directly? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmcgowan do you mean you prefer to make this conditional to keep that option open?
Something like this?;
if ac.ServerAddress == "" {
ac.ServerAddress = creds.ServerAddress
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had not read it that way yet. That makes sense. So we only set it when it is empty and not accidentally overwrite a potential value. I can add that real quick.
@thaJeztah agreed, both changes make sense |
This will return the ServerAddress property when using the NativeStore. This happens when you use docker credential helpers, not the credential store. The reason this fix is needed is because it needs to be propagated properly down towards `moby/moby` project in the following logic: ```golang func authorizationCredsFromAuthConfig(authConfig registrytypes.AuthConfig) docker.AuthorizerOpt { cfgHost := registry.ConvertToHostname(authConfig.ServerAddress) if cfgHost == "" || cfgHost == registry.IndexHostname { cfgHost = registry.DefaultRegistryHost } return docker.WithAuthCreds(func(host string) (string, string, error) { if cfgHost != host { logrus.WithFields(logrus.Fields{ "host": host, "cfgHost": cfgHost, }).Warn("Host doesn't match") return "", "", nil } if authConfig.IdentityToken != "" { return "", authConfig.IdentityToken, nil } return authConfig.Username, authConfig.Password, nil }) } ``` This logic resides in the following file : `daemon/containerd/resolver.go` . In the case when using the containerd storage feature when setting the `cfgHost` variable from the `authConfig.ServerAddress` it will always be empty. Since it will never be returned from the NativeStore currently. Therefore Docker Hub images will work fine, but anything else will fail since the `cfgHost` will always be the `registry.DefaultRegistryHost`. Signed-off-by: Eric Bode <[email protected]>
652cd45
to
b24e7f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
And thanks for the extra eyes, @dmcgowan
This will return the ServerAddress property when using the NativeStore. This happens when you use docker credential helpers, not the credential store.
The reason this fix is needed is because it needs to be propagated properly down towards
moby/moby
project in the following logic:This logic resides in the following file :
daemon/containerd/resolver.go
.In the case when using the containerd storage feature when setting the
cfgHost
variable from theauthConfig.ServerAddress
it will always be empty. Since it will never be returned from the NativeStore currently. Therefore Docker Hub images will work fine, but anything else will fail since thecfgHost
will always be theregistry.DefaultRegistryHost
.- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)